<?php
require_once 'db.class.php';

class Control{
	protected $acao;
	protected $pagina;
	protected $exec;
	protected $class;	
	protected $parametros;
	public $result;
	
	function __construct($acao,$pagina,$parametros) {
		require_once 		strtolower($pagina).'.class.php';
		
		$this->acao 		= $acao;
		$this->pagina 		= $pagina;
		$this->parametros 	= $parametros;
		$this->class 		= $this->pagina.'Model';
		$this->exec 		= $this->acao.ucfirst($this->pagina);		
	}	

	public function Consult(){
		try {
			$this->result = new $this->class();
			$met = $this->exec;
			$this->result->$met($this->parametros);
		} catch (Exception $e) {
			echo 'Erro: ',  $e->getMessage();
		}
	}
	public function Lister(){
		try {
			$this->result = new $this->class();
			$met = $this->exec;
			$this->result->$met($this->parametros);
		} catch (Exception $e) {
			echo 'Erro: ',  $e->getMessage();
		}
	}
	public function Dropdown(){
		try {
			$this->result = new $this->class();
			$met = $this->exec;
			$this->result->$met($this->parametros);
		} catch (Exception $e) {
			echo 'Erro: ',  $e->getMessage();
		}
	}
	
	public function Insert(){
		try {
			$this->result = new $this->class();
			$met = $this->exec;
			$this->result->$met($this->parametros);
		} catch (Exception $e) {
			echo 'Erro: ',  $e->getMessage();
		}
	}
	public function Update(){
		try {
			$this->result = new $this->class();
			$met = $this->exec;
			$this->result->$met($this->parametros);
		} catch (Exception $e) {
			echo 'Erro: ',  $e->getMessage();
		}
	}
	public function Delete(){
		try {
			$this->result = new $this->class();
			$met = $this->exec;
			$this->result->$met($this->parametros);
		} catch (Exception $e) {
			echo 'Erro: ',  $e->getMessage();
		}
	}
}
?>